/**
 * @ Author: luoqi
 * @ Create Time: 2024-07-11 18:28
 * @ Modified by: luoqi
 * @ Modified time: 2025-03-25 19:53
 * @ Description:
 */

#ifndef _BSP_H
#define _BSP_H

#include <stdint.h>
#include <ringbuf.h>
#include <app_azure_rtos.h>

#include <main.h>
#include <usart.h>
#include <gpio.h>
#include <tim.h>
#include <can.h>
#include <adc.h>
#include <dma.h>
#include <usb_otg.h>
#include <usb_device.h>
#include <usbd_cdc_if.h>

typedef enum {
    BSP_LED_OFF = 0,
    BSP_LED_ON = 1,
} BspLedState;

typedef struct {
    int id;
    const char *name;
} NameTable;

#ifndef UNUSED
#define UNUSED(x) ((void)(x))
#endif

#ifndef __WEAK
#define __WEAK __attribute__((weak))
#endif

#ifndef time_t
typedef uint64_t qtime_t;
#endif

#define SET_TO_CCRAM __attribute__((section(".ccmram"))) __attribute__((used))

int bsp_init(void);

int bsp_deinit(void);

void bsp_led_set(BspLedState state);

int bsp_uart1_recv(uint8_t *data, uint32_t len, uint32_t timeout);

int bsp_uart1_received(void);

int bsp_printf(const char *fmt, ...);

void bsp_mdelay(uint32_t ms);

void bsp_udelay(uint32_t us);

qtime_t bsp_ktime(void);

void bsp_reboot(void);

uint32_t bsp_strlen(const char *s);

void *bsp_memcpy(void *dest, const void *src, uint32_t len);

int bsp_sys_init(void);

int bsp_usb_send(const uint8_t *data, uint16_t len);

int bsp_usb_recv(uint8_t *data, uint16_t len, uint32_t timeout);

void bsp_usb_send_flag_set(void);

void bsp_os_startup(void);

void i2c1_txcplt_cb(void);

void i2c1_rxcplt_cb(void);

void i2c2_txcplt_cb(void);

void i2c2_rxcplt_cb(void);

#endif
